import {Injectable} from '@angular/core';
import {BadgeComponent, BadgePipe, SimpleJsonFormatter} from '../../../ng-tools';

@Injectable({
  providedIn: 'root'
})
export class DeviceConfigFormatterService {
  name: SimpleJsonFormatter = {propName: 'name', displayName: '名称'};
  create_position_display: SimpleJsonFormatter = {propName: 'create_position_display', displayName: '告警生成位置', dynamicComponent: {component: BadgeComponent}};
  cpu_load_first_threshold: SimpleJsonFormatter = {propName: 'cpu_load_first_threshold', displayName: 'CPU负荷一级门阀'};
  cpu_load_second_threshold: SimpleJsonFormatter = {propName: 'cpu_load_second_threshold', displayName: 'CPU负荷二级门阀'};
  cpu_load_third_threshold: SimpleJsonFormatter = {propName: 'cpu_load_third_threshold', displayName: 'CPU负荷三级门阀'};
  cpu_load_special_threshold: SimpleJsonFormatter = {propName: 'cpu_load_special_threshold', displayName: 'CPU负荷特殊门阀'};
  cpu_us_sy_usage_threshold: SimpleJsonFormatter = {propName: 'cpu_us_sy_usage_threshold', displayName: 'CPU US+SY使用率门阀'};
  cpu_wa_usage_threshold: SimpleJsonFormatter = {propName: 'cpu_wa_usage_threshold', displayName: 'CPU WA使用率门阀'};
  cpu0_si_usage_threshold: SimpleJsonFormatter = {propName: 'cpu0_si_usage_threshold', displayName: 'CPU0 SI使用率门阀'};
  memory_usage_first_threshold: SimpleJsonFormatter = {propName: 'memory_usage_first_threshold', displayName: '内存使用一级门阀'};
  memory_usage_second_threshold: SimpleJsonFormatter = {propName: 'memory_usage_second_threshold', displayName: '内存使用二级门阀'};
  memory_usage_third_threshold: SimpleJsonFormatter = {propName: 'memory_usage_third_threshold', displayName: '内存使用三级门阀'};
  memory_usage_special_threshold: SimpleJsonFormatter = {propName: 'memory_usage_special_threshold', displayName: '内存使用特殊门阀'};
  disk_usage_first_threshold: SimpleJsonFormatter = {propName: 'disk_usage_first_threshold', displayName: '磁盘使用一级门阀'};
  disk_usage_second_threshold: SimpleJsonFormatter = {propName: 'disk_usage_second_threshold', displayName: '磁盘使用二级门阀'};
  disk_usage_third_threshold: SimpleJsonFormatter = {propName: 'disk_usage_third_threshold', displayName: '磁盘使用三级门阀'};
  disk_usage_special_threshold: SimpleJsonFormatter = {propName: 'disk_usage_special_threshold', displayName: '磁盘使用特殊门阀'};
  receive_rate_first_threshold: SimpleJsonFormatter = {propName: 'receive_rate_first_threshold', displayName: '接受速率一级门阀'};
  receive_rate_second_threshold: SimpleJsonFormatter = {propName: 'receive_rate_second_threshold', displayName: '接受速率二级门阀'};
  receive_rate_third_threshold: SimpleJsonFormatter = {propName: 'receive_rate_third_threshold', displayName: '接受速率三级门阀'};
  receive_rate_special_threshold: SimpleJsonFormatter = {propName: 'receive_rate_special_threshold', displayName: '接受速率特殊门阀'};
  send_rate_first_threshold: SimpleJsonFormatter = {propName: 'send_rate_first_threshold', displayName: '发送速率一级门阀'};
  send_rate_second_threshold: SimpleJsonFormatter = {propName: 'send_rate_second_threshold', displayName: '发送速率二级门阀'};
  send_rate_third_threshold: SimpleJsonFormatter = {propName: 'send_rate_third_threshold', displayName: '发送速率三级门阀'};
  send_rate_special_threshold: SimpleJsonFormatter = {propName: 'send_rate_special_threshold', displayName: '发送速率特殊门阀'};

  constructor(public badgePipe: BadgePipe) {
    this.create_position_display.pipe = {pipeTransform: this.badgePipe, args: [['设备管理服务器', '本地设备'], ['badge-info', 'badge-warning']]};
  }

  get formatter(): SimpleJsonFormatter[] {
    return [
      this.name,
      this.create_position_display,
      this.cpu_load_first_threshold,
      this.cpu_load_second_threshold,
      this.cpu_load_third_threshold,
      this.cpu_load_special_threshold,
      this.cpu_us_sy_usage_threshold,
      this.cpu_wa_usage_threshold,
      this.cpu0_si_usage_threshold,
      this.memory_usage_first_threshold,
      this.memory_usage_second_threshold,
      this.memory_usage_third_threshold,
      this.memory_usage_special_threshold,
      this.disk_usage_first_threshold,
      this.disk_usage_second_threshold,
      this.disk_usage_third_threshold,
      this.disk_usage_special_threshold,
      this.receive_rate_first_threshold,
      this.receive_rate_second_threshold,
      this.receive_rate_third_threshold,
      this.receive_rate_special_threshold,
      this.send_rate_first_threshold,
      this.send_rate_second_threshold,
      this.send_rate_third_threshold,
      this.send_rate_special_threshold
    ];
  }
}
